package com.letoy.edu.service.Impl;

import com.letoy.edu.dao.UserApiMapper;
import com.letoy.edu.entity.MyApi;
import com.letoy.edu.service.UserApiService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@Service
public class UserApiServiceImpl implements UserApiService {
    @Resource
    UserApiMapper userApiMapper;

    @Override
    public List<MyApi> getMyApiListByUserId(String id) {
        return userApiMapper.getApiListByUserId(id);
    }

    @Override
    public boolean cleanToken(String token) {
        return userApiMapper.cleanToken(token) >= 1;
    }

    @Override
    public HashMap<String, Object> insertApi(MyApi myApi) {
        HashMap<String, Object> hashMap = new HashMap<>();

        int i = userApiMapper.insertApi(myApi);
        if (i == 0) {
            hashMap.put("status", "1");
            hashMap.put("msg", "插入失败");
            return hashMap;
        }
        hashMap.put("status", "0");
        hashMap.put("msg", "插入成功");
        return hashMap;
    }
}
